package P3;

import Graphing.GnutellaGraph;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;

public class GraphTest
{
    public static void main(String[] args) throws Exception
    {
        GnutellaGraph graph = new GnutellaGraph(2048, 2048);
        LoadGraph(graph);
        
        graph.DrawToFile("GraphTest");
    }
    
    public static void LoadGraph(GnutellaGraph graph) throws Exception
    {   
        FileReader fr = new FileReader(new File("Results.log"));
        BufferedReader in = new BufferedReader(fr);
        
        CrawlResult result = null;
        StringBuilder text = null;
        String line = null;
        while(true)
        {
            text = new StringBuilder();
            result = new CrawlResult();
            for(int i = 0; i < 12; ++i)
            {
                line = in.readLine();
                if(line == null)
                {
                    System.out.println("Num Nodes: " + graph.GetNumNodes());
                    return;
                }
                text.append(line + "\n");
            }
            result.LoadFromString(text.toString());
            graph.ProcessResult(result);
        }
    }
}
